package com.jilujia.domain.question.service;

import java.util.List;

import org.springframework.data.domain.Page;

import com.jilujia.domain.question.Answer;
import com.jilujia.domain.question.AnswerComment;
import com.jilujia.domain.question.Question;
import com.jilujia.domain.question.QuestionTag;
import com.jilujia.domain.region.Region;
import com.jilujia.framework.domain.SearchCriteria;

/**
 * A service interface for retrieving hotels and bookings from a backing repository. Also supports the ability to cancel
 * a booking.
 */
public interface QuestionService {

	Page<Question> findQuestionsByCriteria(SearchCriteria criteria);

	Page<Answer> findAnswersByCriteria(Long questionId, SearchCriteria criteria);

	Page<AnswerComment> findAnswerCommentsByCriteria(Long answer, SearchCriteria criteria);

	Page<Question> findQuestionsByTagCriteria(String tagName, SearchCriteria criteria);

	Page<QuestionTag> findQuestionTagsByCriteria(SearchCriteria criteria);

	Question createQuestion();

	Question persistQuestion(Question questionVo, Long userId);

	Question findQuestionById(Long id);

	Integer findQuestionViewCountById(Long questionId);

	Answer createAnswer(Question question);

	Answer persistAnswer(Answer answerVo, Long userId);

	AnswerComment createAnswerComment();

	AnswerComment persistAnswerComment(AnswerComment answerCommentVo, Long userId);

	QuestionTag findQuestionTagByName(String tagName);

	List<QuestionTag> findTagsByQuestionId(Long questionId);

	/**
	 * 记录用户的投票，并修改answer的vote count
	 * 
	 * @param userId
	 * @param answerId
	 * @param useful
	 */
	void voteAnswer(Long answerId, Long userId, boolean useful);

	void voteQuestion(Long questionId, Long userId, boolean useful);

	List<QuestionTag> findAssociatedQuestionTags(QuestionTag tag);

	List<Question> findTop10QuestionsByRegion(Region region);

	public void refleshQuestionViewCount();

}
